﻿using System;
using System.Text;

namespace XStudio.XCRF.Utilities.Base64Encryption
{
    public static class Base64Extension
    {
        /// <summary>
        /// 将指定字符串进行Base64加密
        /// </summary>
        /// <param name="input">输入字符串</param>
        /// <returns>生成的Base64密文</returns>
        public static string Base64Encode(this string input)
        {
            byte[] bytes = Encoding.UTF8.GetBytes(input);
            string output = Convert.ToBase64String(bytes);
            return output;
        }
        /// <summary>
        /// 将Base64密文解密
        /// </summary>
        /// <param name="input">密文字符串</param>
        /// <returns>解密后的字符串</returns>
        public static string Base64Decode(this string input)
        {
            byte[] bytes = Convert.FromBase64String(input);
            string output = Encoding.UTF8.GetString(bytes);
            return output;
        }
    }
}
